package appjam;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class InitDataServlet extends HttpServlet {
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		
		Jam j1 = new Jam("Punto 1", "Sevilla", "37.383457402837706", "-5.974674224853516");
		Jam j2 = new Jam("Punto 2", "Pueblo 1", "37.27459920466868", "-5.038604736328125");
		Jam j3 = new Jam("Punto 3", "Madrid", "40.435254164648555", "-3.6922645568847656");
		
		List<Jam> jams = new ArrayList<Jam>();
		jams.add(j1);
		jams.add(j2);
		jams.add(j3);
		
		try {
			pm.makePersistentAll(jams);
		} finally {
			pm.close();
		}
		
		resp.sendRedirect("/index.html");
	}

}
